const SET_TOKEN = 'SET_TOKEN'

 import {
 	getUserInfo as getUserInfoApi
 } from '@/api/user.js'


 function initState() {
 	return {
 		token: '',
 		userInfo: {}
 	}
 }


 export default {
 	nameSpaced: true,
 	state() {
 		return initState()
 	},
 	mutations: {
 		SET_TOKEN(state, val) {
 			state.token = val
 		},
 		SET_USERINFO(state, val) {
 			state.userInfo = val
 		}

 	},
 	actions: {

 		async getUserInfo({commit}) {

 			let res = await  getUserInfoApi()
		     commit('SET_USERINFO',res)
		     commit('SET_TOKEN',uni.getStorageSync('token'))
			return res

 		}
		
		// getUserInfo     返回值 是一个Promise
		
		

 	}

 }
